' *** Documentation
' 
' Klenwell VbScript Object Template
' 
' last updated: Oct 2007
' author: klenwell@gmail.com
' 
' Public Methods
'   
' 
' NOTES
'   This is the template I use for Vbscript classes.  The syntax probably
'   doesn't reflect conventional vbs syntax, but that's because I don't
'   really like conventional vbs syntax.  Replace this description in your
'   class.
' 
' ____________________________________________________________________________*/


' -- BEGIN CLASS -----------------------------------------------------------
Class ClassName

' -- PROPERTIES ------------------------------------------------------------

' Utility Properties
Public debug
Public cid      ' class id/name

' Public Properties
Public public_prop
Public PUBLIC_ARRAY

' Private Properties
Private m_private_prop
Private m_PRIVATE_ARRAY


' -- METHODS ---------------------------------------------------------------
' -- CONSTRUCTOR AND UTILITY METHODS ---------------------------------------    
' Constructor
Private Sub Class_Initialize()
  debug = 0
  cid = "class_id"
End Sub


' Print Force
Public Sub print_f(str)
  MsgBox(str)
End Sub


' Print when Debug set
Public Sub print_d(str)
  if ( debug ) Then: print_f(str): End If
End Sub


' Trigger Error
Public Sub trigger_error(src, msg)
  Dim num: num = 100
  src = cid & ": " & src
  Err.Raise num, src, msg
End Sub


' Fatal Error
Public Sub fatal_error(src, msg)
  trigger_error src, msg
  print_f "fatal error: quitting application"
  Wscript.Quit
End Sub


' Reset class
Public Sub Reset()
  ' reset operations
End Sub



' -- PUBLIC METHODS --------------------------------------------------------
' Public Function
Public Function fx(arg)
  var = arg
End Function



' -- PRIVATE METHODS -------------------------------------------------------
' Private Sub
Private Sub m_sub(str)
  print_d(str)
End Sub



' -- END CLASS -------------------------------------------------------------  
End Class





' -- TEST ------------------------------------------------------------------  
If ( True ) Then
  Dim iT1: iT1 = Timer
  MsgBox("begin testing")
  
  
  ' Test 0: Create object
  Dim TestClass: Set TestClass = new ClassName
  
  ' Test 1: Debug
  if ( 1 ) Then
    TestClass.print_d "this should not print"
    TestClass.debug = 1
    TestClass.print_d "this should print"
  End If

  ' Test 2: ?
  If ( 1 ) Then
  End If
  
  ' Test Last: Error Test
  If ( 1 ) Then
    TestClass.fatal_error "src: testbed", "fatal error test"
  End If 
  
  
  ' Finish
  Dim iT2: iT2 = Timer - iT1
  MsgBox("test complete in " & iT2 & " s")
End If


